package com.component;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by pengfei on 16/7/6.
 */
@Configuration
public class ServiceBeanAutoConfig {
    //@Bean 是一个方法级别的注解,相当于xml中<bean> 节点,方法的名字就是bean的name
    //@Configuration 是一个类级别的注解,他表示这个类里会声明一个或多个 @Bean 方法,并且会被spring容器扫描生成bean definitions
    //@ConditionalOnMissingBean 用来表明这个bean定义到底生不生效
    @Bean(initMethod = "haha")
    @ConditionalOnMissingBean
    public PersonService personService(){
        PersonService service = new PersonService();
        service.setName("xxxxxx");
        return service;
    }
}
